export default function registerJiedian (lf) {
  lf.register('jiedian', ({ CircleNode, CircleNodeModel, h }) => {
    class StartNode extends CircleNode {
      getLabelShape () {
        const attributes = this.getAttributes()
        const {
          x,
          y,
          width,
          height
        } = attributes
        return h(
          'svg',
          {
            x: x - width / 2,
            y: y - height / 2,
            width: 40,
            height: 40,
            viewBox: '0 0 1024 1024',
          },
          h(
            'path',
            {
              fill: '#1296db',
              d: 'M79.741221 601.361127c11.169891-1.861982 18.617818-7.446927 26.064746-13.031872 7.447927-7.447927 11.170891-14.894855 9.309909-24.203764v-7.446927c0-143.3586 80.057218-275.547309 204.798-346.295619 9.308909-5.584945 13.031873-13.031873 16.755836-20.4798 1.861982-9.308909 1.861982-18.617818-3.723963-26.064745-5.584945-9.309909-11.169891-14.894855-20.4798-16.755836-11.169891-3.723964-18.617818-1.861982-27.926728 3.722963C135.593676 234.587709 44.366567 390.978182 44.366567 558.539546v14.894854c1.861982 14.894855 16.756836 27.926727 35.374654 27.926727z m623.702909-389.1162c126.602764 70.749309 206.659982 202.936018 206.659982 346.294619v5.585945c-1.861982 9.308909 0 16.755836 5.584946 22.341782 7.447927 9.308909 14.894855 14.893855 27.927727 14.893854h3.722964c16.756836 0 31.650691-13.031873 33.512672-31.649691v-13.032872c0-167.562364-91.229109-323.953836-240.172654-405.873037-9.308909-5.584945-16.755836-5.584945-27.926727-3.722963-9.308909 1.860982-14.893855 9.308909-22.341782 16.755836-5.584945 9.309909-7.446927 18.617818-3.722964 26.064745 3.722964 11.170891 9.308909 18.618818 16.755836 22.341782z m27.926728 679.557364h-9.308909l-9.308909 3.723964c-122.8788 70.748309-284.855218 70.748309-407.734019 0l-3.723963-1.861982h-11.169891c-20.4798 0-33.512673 14.893855-33.512673 35.373654 0 13.032873 5.584945 22.341782 16.755836 31.650691 70.749309 40.9596 152.668509 63.301382 238.310673 63.301382 83.781182 0 167.561364-22.341782 238.309673-65.163364 16.756836-13.031873 20.4798-22.340782 20.4798-31.64969-3.722964-18.618818-18.617818-35.374655-39.097618-35.374655z'
            }
          ),
          h(
            'path',
            {
              fill: '#1296db',
              d: 'M1010.64113 740.996764c-7.446927-33.512673-29.789709-63.301382-59.577418-80.058218-22.341782-14.893855-46.545545-14.893855-63.301382-14.893855-33.512673 0-63.301382 13.032873-87.504145 35.373655l-1.861982 1.861981-106.122963-61.4394v-1.861981c7.446927-22.340782 11.170891-42.820582 11.17089-61.4394 0-89.366127-63.301382-165.699382-152.668509-184.318201h-1.859982V249.481564h1.859982c53.993473-14.894855 91.229109-65.163364 91.229109-122.8788C638.280767 57.715436 582.427312 0 511.679003 0S385.076239 57.715436 385.076239 128.463745c0 55.854455 35.374655 104.260982 91.22911 122.8788h1.860981v121.017819h-3.723963c-89.366127 16.755836-152.667509 94.951073-152.667509 184.3182 0 22.340782 3.723964 42.820582 11.170891 61.4394v1.860982l-106.121964 61.4394-1.861982-1.860982c-24.203764-20.4798-57.716436-33.512673-87.505145-33.512673-26.064745 0-50.268509 9.308909-63.301382 14.893855-29.788709 14.894855-50.268509 42.821582-57.715437 76.334254s-7.446927 68.886327 9.30991 96.814055c18.616818 40.9596 61.4394 65.162364 109.844927 65.162363 29.789709 0 52.130491-11.169891 63.301382-14.893854 48.407527-26.065745 72.610291-81.9192 57.716436-139.635637v-1.861981l104.259982-59.577419 1.861982 1.861982c35.374655 40.9596 89.367127 65.163364 141.496618 65.163364 55.854455 0 106.122964-22.341782 143.3586-65.163364l1.861982-1.861982 104.260982 59.577419v1.861981c-11.169891 52.130491 11.170891 106.122964 57.715436 137.773655 18.618818 13.032873 48.407527 20.4798 76.334254 20.4798 5.584945 0 11.169891 0 14.894855-1.861982 39.097618-5.584945 68.886327-24.203764 91.228109-59.577418 24.202764-40.9596 24.202764-67.025345 16.755836-100.537018z m-817.330018 44.682563c-3.723964 14.894855-14.894855 26.065745-27.926727 33.512673-9.309909 7.446927-16.756836 9.309909-29.789709 9.309909-20.4798 0-40.9596-13.033873-50.268509-29.789709-7.446927-13.032873-11.169891-27.926727-7.446928-42.821582s13.032873-26.064745 27.926728-35.373654c9.309909-5.585945 16.756836-9.309909 27.927727-9.309909 20.4798 0 40.9596 13.032873 50.268509 29.789709 11.169891 14.893855 11.169891 31.649691 9.308909 44.682563zM452.100585 128.463745c0-31.649691 26.064745-57.715436 57.715436-57.715436s57.715436 26.065745 57.715437 57.715436c0 31.650691-26.064745 57.716436-57.715437 57.716437S452.100585 158.253455 452.100585 128.463745z m59.577418 547.369655c-65.163364 0-121.016818-52.129491-121.016818-119.154836 0-67.025345 53.991473-119.155836 121.016818-119.155837 65.162364 0 121.016818 52.130491 121.016818 119.155837-1.861982 65.162364-53.992473 119.154836-121.016818 119.154836z m426.351837 122.8788c-11.169891 18.617818-27.926727 27.926727-46.544546 27.926727-11.170891 0-24.203764-1.861982-33.512673-9.308909-13.032873-9.308909-24.203764-20.4798-27.926727-37.235636-3.723964-13.032873-1.861982-26.065745 7.446927-37.236636 11.169891-18.617818 29.788709-29.788709 48.406528-31.649691h5.585945c11.169891 0 22.340782 1.860982 33.511673 13.031872 22.341782 18.617818 26.065745 46.545545 13.032873 74.472273z'
            }
          ),
        )
      }
      getShape () {
        const attributes = this.getAttributes();
        const {
          x,
          y,
          r,
          fill,
          stroke,
          strokeWidth
        } = attributes
        return h(
          'g',
          {
          },
          [
            h(
              'circle',
              {
                cx: x,
                cy: y,
                r,
                fill,
                stroke,
                strokeWidth
              }
            ),
            this.getLabelShape(),
          ]
        )
      }
    }
    class StartModel extends CircleNodeModel {
      constructor (data, graphModel) {
        data.text = {
          value: (data.text && data.text.value) || '节点',
          x: data.x,
          y: data.y + 35,
          dragable: false,
          editable: true,
        }
        super(data, graphModel)
      }
      getConnectedTargetRules () {
        const rules = super.getConnectedTargetRules()
        const notAsTarget = {
          message: '起始节点不能作为连线的终点',
          validate: () => false
        }
        rules.push(notAsTarget)
        return rules
      }
    }
    return {
      view: StartNode,
      model: StartModel
    }
  })
}
